package com.ruoyi.project.cha.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.cha.domain.HosSal;
import com.ruoyi.project.cha.service.IHosSalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 退费查询Controller
 * 
 * @author zhuxinbo
 * @date 2021-03-24
 */
@RestController
@RequestMapping("/cha/sal")
public class HosSalController extends BaseController
{
    @Autowired
    private IHosSalService hosSalService;

    /**
     * 查询退费查询列表
     */
    @PreAuthorize("@ss.hasPermi('cha:sal:list')")
    @GetMapping("/list")
    public TableDataInfo list(HosSal hosSal)
    {
        startPage();
        List< HosSal > list = hosSalService.selectHosSalList(hosSal);
        return getDataTable(list);
    }

    /**
     * 导出退费查询列表
     */
    @PreAuthorize("@ss.hasPermi('cha:sal:export')")
    @Log(title = "退费查询", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HosSal hosSal)
    {
        List< HosSal > list = hosSalService.selectHosSalList(hosSal);
        ExcelUtil< HosSal > util = new ExcelUtil< HosSal >( HosSal.class);
        return util.exportExcel(list, "sal");
    }

    /**
     * 获取退费查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('cha:sal:query')")
    @GetMapping(value = "/{inqReg}")
    public AjaxResult getInfo(@PathVariable("inqReg") Long inqReg)
    {
        return AjaxResult.success(hosSalService.selectHosSalById(inqReg));
    }

    /**
     * 新增退费查询
     */
    @PreAuthorize("@ss.hasPermi('cha:sal:add')")
    @Log(title = "退费查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HosSal hosSal)
    {
        return toAjax(hosSalService.insertHosSal(hosSal));
    }

    /**
     * 修改退费查询
     */
    @PreAuthorize("@ss.hasPermi('cha:sal:edit')")
    @Log(title = "退费查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HosSal hosSal)
    {
        return toAjax(hosSalService.updateHosSal(hosSal));
    }

    /**
     * 删除退费查询
     */
    @PreAuthorize("@ss.hasPermi('cha:sal:remove')")
    @Log(title = "退费查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{inqRegs}")
    public AjaxResult remove(@PathVariable Long[] inqRegs)
    {
        return toAjax(hosSalService.deleteHosSalByIds(inqRegs));
    }
}
